<?php
include "../../fun.php";
isLogin();
$db=conndb();
$product_name=$_POST["product_name"]; //获取索引
$sortid=$_POST["sortid"];
$content=isset($_POST["content"])?$_POST["content"]:'';
$pic=$_POST["pic"];
$time=strtotime($_POST["time"]);
$id=isset($_POST["id"])?$_POST["id"]:'';
if ($id) {
    $sql="update product set product_name='{$product_name}',content='{$content}',pic='{$pic}',sortid='{$sortid}',time='{$time}' where id='{$id}'";
} else {
    $sql="insert into product (product_name,content,pic,sortid,time) values ('{$product_name}','{$content}','{$pic}','{$sortid}','{$time}')";
}
$db->exec($sql);
$data=["code"=>0,"msg"=>"操作成功"];
echo json_encode($data, JSON_UNESCAPED_UNICODE);
